using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using MimeCloud.AssetManagement.Business.Interface;

namespace MimeCloud.AssetManagement.DataProvider.Sql.Entities
{
    [InheritanceMapping(Type=typeof(AssetMetadata))]
    [InheritanceMapping(Type = typeof(AssetContentMetadata))]
    public class Metadata : IMetaData
    {
        [Column(Name="MetaKeyID_FK")]
        public virtual int MetaKeyID { get; set; }
        [Column(Name="MetaValueID_FK")]
        public virtual int MetaValueID { get; set; }

        public Metadata()
        {
            _MetaKey = default(EntityRef<MetaKey>);
            _MetaValue = default(EntityRef<MetaValue>);
        }
        

        internal EntityRef<MetaKey> _MetaKey;
        internal EntityRef<MetaValue> _MetaValue;

        [Association(ThisKey = "MetaKeyID", OtherKey="ID",Storage = "_MetaKey", DeleteOnNull = true, IsForeignKey = true)]
        internal virtual MetaKey MetaKeyE { get { return _MetaKey.Entity; } set { _MetaKey.Entity = value; } }
        public IMetaKey MetaKey { get { return _MetaKey.Entity; } set { _MetaKey.Entity = value as MetaKey; } }

        [Association(ThisKey="MetaValueID",OtherKey="ID",Storage="_MetaValue",DeleteOnNull=true,IsForeignKey=true)]
        internal virtual MetaValue MetaValueE { get { return _MetaValue.Entity; } set { _MetaValue.Entity = value; } }
        public IMetaValue MetaValue { get { return _MetaValue.Entity; } set { _MetaValue.Entity = value as MetaValue; } }
    }
}
